package starfire.task;

/**
 * <p>Title: JFtp</p>
 * <p>Description: ftp client</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author starfire
 * @version 1.0
 */

/*
 * exception class for task;
 */
public class TaskException extends Exception {
  public final static int CANTCONNECT = 0;
  public final static int TOOMANYUSERS = 1;
  public final static int USERNOTACCEPT = 2;
  public final static int BADPASSWORD = 3;
  public final static int TIMEOUT = 4;
  public final static int CANTFINDFILE = 5;
  public final static int RECVREPLYFAILED = 6;
  public final static int IOERROR = 7;
  public final static int UNKNOWN = 15;

  private int type = 5;

  public TaskException(int type) {
    this.type = type;
  }

  public int getType()
  {
    return type;
  }

  public String toString()
  {
    switch (type)
    {
      case TaskException.CANTCONNECT :
        return "can't connect";
      case TaskException.USERNOTACCEPT :
        return "user name not accept";
      case TaskException.BADPASSWORD :
        return "bad password";
      case TaskException.TIMEOUT :
        return "time out";
      case TaskException.CANTFINDFILE :
        return "can't find file";
      case TaskException.RECVREPLYFAILED:
        return "receive server's reply failed";
      case TaskException.IOERROR:
        return "io error";
      default :
        return "unknown exception";
    }
  }

}